﻿#region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;

    using Csla;

    using MarketPulse.BusinessLogic.Core;

#endregion

namespace MarketPulse.BusinessLogic.Common
{
    /// <summary>
    /// </summary>
    [Serializable]
    [Csla.Server.ObjectFactory("MarketPulse.BusinessLogic.DataAccess.LinqSProcFrequencyTypeFactory, DataAccess")]
    public class FrequencyTypeList : MarketPulseNameValueListBase<Guid, string>
    {
        #region Member Variables

            private static FrequencyTypeList mFrequencyTypes;

        #endregion

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            private FrequencyTypeList()
            {
            }

        #endregion

        #region Methods

            #region Factory Methods

                /// <summary>
                /// Method used to get a list of name/value pairs representing FrequencyTypes 
                /// from the database.  Internally this accesses a static field so this
                /// class is effectively a lazily instantiated singleton.
                /// </summary>
                public static void GetList(EventHandler<DataPortalResult<FrequencyTypeList>> callback)
                {

                    if (mFrequencyTypes == null)
                    {
                        DataPortal.BeginFetch<FrequencyTypeList>((o, e) =>
                        {
                            mFrequencyTypes = e.Object;
                            callback(o, e);
                        });
                    }
                    else
                    {
                        callback(null, new DataPortalResult<FrequencyTypeList>(mFrequencyTypes, null, null));
                    }
                }

                /// <summary>
                /// Method used to update the list of name/value pairs representing FrequencyTypes
                /// </summary>
                /// <param name="frequencyTypes">The list of name/value pairs to update</param>
                /// <returns>The name/value list resulting from the update</returns>
                public static FrequencyTypeList UpdateFrequencyTypes(FrequencyTypeList frequencyTypes)
                {
                    return DataPortal.Update<FrequencyTypeList>(frequencyTypes);
                }

            #endregion

        #endregion

        #region Properties

        #endregion

    }
}
